package admin

// 教师资质
import (
	"duoke/model"
	"duoke/service"
	"duoke/utils/gconv"
	"duoke/utils/request"
	"duoke/utils/response"
	"github.com/gin-gonic/gin"
)

var CourseLecturer = new(courseLecturerCtl)

type courseLecturerCtl struct{}

func (ctl *courseLecturerCtl) List(c *gin.Context) {
	var req model.ReqList
	if err := c.ShouldBindJSON(&req); err != nil {
		response.Error(c, err.Error(), nil)
		return
	}
	list, total, err := service.CourseLecturer.List(c, &req)
	if err != nil {
		response.Error(c, err.Error(), nil)
		return
	}
	response.Success(c, "获取成功", gin.H{"total": total, "list": list})
	return
}
func (ctl *courseLecturerCtl) Save(c *gin.Context) {
	var req model.CourseLecturerTab
	if err := c.ShouldBindJSON(&req); err != nil {
		response.Error(c, err.Error(), nil)
		return
	}
	list, err := service.CourseLecturer.Save(c, &req)
	if err != nil {
		response.Error(c, err.Error(), nil)
		return
	}
	response.Success(c, "保存成功", gin.H{"data": list})
	return
}
func (ctl *courseLecturerCtl) Del(c *gin.Context) {
	req := request.JsonMap(c)
	id := gconv.Int(req["id"])
	list, err := service.CourseLecturer.Del(id)
	if err != nil {
		response.Error(c, err.Error(), nil)
		return
	}
	response.Success(c, "删除成功", gin.H{"data": list})
	return
}
